package com.demo.index;

import com.demo.common.model.Cart;
import com.demo.common.model.User;

import java.util.List;

public class IndexService {

    private User user=new User().dao();

    private Cart cart=new Cart().dao();

    //登录
    public User sign(String username,String password){
        String sql="select * from user where (nickname='"+username+"' or email='"+username+"' or tel='"+username+"') and password='"+password+"'";
        return user.findFirst(sql);
    }

    public User findUserById(int id) {
        return user.findById(id);
    }

    public void deleteUserById(int id) {
        user.deleteById(id);
    }

    //购物车列表
    public List<Cart> cartlist(){
        String sql="select * from cart where visble=0 order by id asc";
        return cart.find(sql);
    }

    public Cart findCartById(int id) {
        return cart.findById(id);
    }

    public void deleteCartById(int id) {
        cart.deleteById(id);
    }
}
